package tech.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.Post;
import tech.aistar.entity.PostVo;
import tech.aistar.entity.Theme;
import tech.aistar.service.IPostService;
import tech.aistar.service.IThemeService;

import java.util.List;

/**
 * Created by Administrator on 2019/10/10.
 */
@Controller
@RequestMapping("/forumF")
public class ForumAction {
    @Autowired
    private IPostService postService;
    @Autowired
    private IThemeService themeService;

    /**
     * 进入论坛首页
     */
    @RequestMapping("/forumFather")
    public String forums(Model model,Integer postId,Integer themeId){
        //热帖
        List<PostVo> postvoList = postService.findAllPost();
        model.addAttribute("postvoList",postvoList);

        //主题
        Long postNum = postService.findPostNumByTheme(themeId);
        model.addAttribute("postNum",postNum);

        List<Theme> themeList = themeService.findAllTheme();
        System.err.println(themeList+"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        model.addAttribute("themeList",themeList);

        //主题对应帖子数(暂时这么查)
        Long postThemeNum = postService.findPostNumByTheme(themeId);
        model.addAttribute("postThemeNum",postThemeNum);
        return "/forum/forum";
    }

}
